<?php
/**
 * Created by PhpStorm.
 * User: Thuan
 * Date: 11/27/13
 * Time: 9:36 PM
 */

class Helper {
    const FormatDateInput = "Y-m-d H:i:s";
    const FormatDate = "Y-m-d H:i:s";
    /**
     * @return string ip of client
     */
    public static function getUserIP(){
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }

    /**
     * @return string
     */
    public static function getCurrentDateTime(){
        return date(self::FormatDate);
    }

    public static function getDateTime($time){
        //return date(self::FormatDate,date_create_from_format(self::FormatDateInput,$time)->getTimestamp());
        return $time;
    }

} 